package nicewarm.com.airbansearchanimation.view;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.bigkoo.convenientbanner.holder.Holder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import nicewarm.com.airbansearchanimation.R;

/**
 * Created by luoxf on 17-3-16.
 */

public class BannerHolderView implements Holder<String> {
    private final static String TAG = BannerHolderView.class.getSimpleName();
    private ImageView mImageView;

    @Override
    public View createView(Context context) {
        mImageView = (ImageView) LayoutInflater.from(context).inflate(R.layout.banner_imageview, null);
        return mImageView;
    }

    @Override
    public void UpdateUI(Context context, int position, String data) {
        if (TextUtils.isEmpty(data)) {
            Log.e(TAG, "iamge url is null");
        } else {
            Glide.with(context)
                    .load(data)
                    .centerCrop()
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .crossFade(500)
                    .into(mImageView);
        }
    }
}
